package com.heima.behavior.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.heima.behavior.mapper.LoadArticleBehaviorMapper;
import com.heima.behavior.service.LoadArticleBehaviorService;
import com.heima.model.article.dtos.ArticleBehaviorDto;
import com.heima.model.behavior.pojos.BeBehavior;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoadArticleBehaviorServiceImpl implements LoadArticleBehaviorService {
    @Autowired
    private LoadArticleBehaviorMapper loadArticleBehaviorMapper;
    @Override
    public ResponseResult loadArticleBehavior(ArticleBehaviorDto dto) {
        LambdaQueryWrapper<BeBehavior> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BeBehavior::getArticleId,dto.getArticleId());
        queryWrapper.eq(BeBehavior::getAuthorId,dto.getAuthorId());
        BeBehavior behavior = loadArticleBehaviorMapper.selectOne(queryWrapper);
        ResponseResult result = new ResponseResult();
        result.setData(behavior);
        return result;
    }
}
